Lab 3

  1. Write a C++ program that does the following:
  2. Sample run of program:
    Enter a value for x: 5 Enter a value for y: 4 The sum of 5 and 4 is 9 4 subtracted from 5 is 1 The product of 5 and 4 is 20 The average of 5 and 4 is 4.5 The remainder when 5 is divided by 4 is 1
  3. Write a program that computes and prints the area and perimeter of a letter-size (8.5 x 11 inches) sheet of paper. Please do not work with numbers; work with variables.
  4. Sample run of program:
    The area of letter-size sheet of paper is 93.5 The perimeter of a letter-size sheet of paper is 39
  5. Write a C++ program that prompts a user to enter a four-digit integer and prints the number in reverse. HINT: Print one digit at a time, starting from the right of the number.
  6. Sample run of program:
    Enter a four-digit number: 3412 Your number in reverse is 2143
  7. Ask the user to enter his/her name and his/her height in inches. Store the name in a string variable and the height in an int variable. Convert the height to centimeters.
  8. Sample run of program:
    Enter your name: Dave Enter your height in inches: 61 Hi Dave. You are 154.94 centimeters tall.

  9. Write a program that computes the total score for a basketball game. Prompt the user for the number of 3-pointers scored and 2-pointers scored and find the final points for the team. Print that total to the monitor.
  10. Sample run of program:
    How many 3-pointers? > 10 How many 2-pointers? 7 Total points scored: 44